package org.lottery.panel;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;

import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;

import org.come.model.Shop;
import org.come.mouslisten.AddTeXiaoMouslisten;
import org.come.until.CutButtonImage;
import org.come.until.GoodsListFromServerUntil;

import com.tool.btn.ShoppingBuyBtn;
import com.tool.tcpimg.UIUtils;



public class LotteryIntegralGoodsJpanel extends JPanel {

	private ShoppingBuyBtn btnBuy;// 购买按钮
	private JLabel labBorder,// 背景框
			labImg;// 特效图片展示

	public ImageIcon icon = CutButtonImage.getImage("inkImg/old/background/8.png", 44, 43);
	private AddTeXiaoMouslisten xiaoMouslisten;
	private Shop shop;

	public LotteryIntegralGoodsJpanel(Shop shop) {
		this.setPreferredSize(new Dimension(250, 65));
		this.setLayout(null);
		this.setOpaque(false);
		this.setBackground(UIUtils.Color_BACK);
		this.shop = shop;
		xiaoMouslisten = new AddTeXiaoMouslisten();
		// 特效图片展示
		labImg = new JLabel();
		labImg.setBounds(21, 8, 42, 41);
		labImg.setIcon(GoodsListFromServerUntil.imgpathAdaptive(shop.getShopskin(), 42, 41));
		labImg.addMouseListener(xiaoMouslisten);
		this.add(labImg);

		// 购买按钮
		btnBuy = new ShoppingBuyBtn("skin/8100226/newbutton/B20.png", 1, "兑换", 4, this);
		btnBuy.setBounds(170, 24, 59, 24);
		this.add(btnBuy);

		// 背景框
		labBorder = new JLabel();
		labBorder.setBounds(20, 7, 44, 43);
		labBorder.setIcon(icon);
		this.add(labBorder);

	}

	private ImageIcon iconLine;

	@Override
	protected void paintComponent(Graphics g) {
		// TODO Auto-generated method stub
		super.paintComponent(g);
		if (iconLine == null) {
			iconLine = CutButtonImage.getImage("inkImg/hongmu/2/分割线_w225,h1.png", 225, 1);
		}
		if (shop != null) {
			g.drawImage(iconLine.getImage(), 14, 62, 225, 1, this);
			g.setFont(UIUtils.TEXT_FONT1);
			g.setColor(Color.white);
			g.drawString(shop.getShopname(), 81, 20);
			g.setColor(UIUtils.COLOR_Wing1);
			g.drawString("积分：" + shop.getShopprice(), 81, 50);
		}

	}

	/**
	 * 清空界面的方法
	 */
	public void clearWindow() {
		// name = "";
		// value = "";
		shop = null;
		labImg.setIcon(null);
		btnBuy.setBtn(0);
		btnBuy.setIcon(null);
		btnBuy.setText("");
		labBorder.setIcon(null);
		xiaoMouslisten.setEshop(null);
	}

	// 修改物品信息
	public void getShopData(Shop shop) {
		this.shop = shop;
		labImg.setIcon(GoodsListFromServerUntil.imgpathAdaptive(shop.getShopskin(), 42, 41));
		labBorder.setIcon(icon);
		btnBuy.setBtn(1);
	}

	public ShoppingBuyBtn getBtnBuy() {
		return btnBuy;
	}

	public void setBtnBuy(ShoppingBuyBtn btnBuy) {
		this.btnBuy = btnBuy;
	}

	public JLabel getLabImg() {
		return labImg;
	}

	public void setLabImg(JLabel labImg) {
		this.labImg = labImg;
	}

	// public String getName() {
	// return name;
	// }
	// public void setName(String name) {
	// this.name = name;
	// }
	// public String getValue() {
	// return value;
	// }
	// public void setValue(String value) {
	// this.value = value;
	// }
	public JLabel getLabBorder() {
		return labBorder;
	}

	public void setLabBorder(JLabel labBorder) {
		this.labBorder = labBorder;
	}

	public AddTeXiaoMouslisten getXiaoMouslisten() {
		return xiaoMouslisten;
	}

	public void setXiaoMouslisten(AddTeXiaoMouslisten xiaoMouslisten) {
		this.xiaoMouslisten = xiaoMouslisten;
	}

	public ImageIcon getIcon() {
		return icon;
	}

	public void setIcon(ImageIcon icon) {
		this.icon = icon;
	}

	public Shop getShop() {
		return shop;
	}

	public void setShop(Shop shop) {
		this.shop = shop;
	}

	public ImageIcon getIconLine() {
		return iconLine;
	}

	public void setIconLine(ImageIcon iconLine) {
		this.iconLine = iconLine;
	}

}
